//
//  VCOFSecond.m
//  UI07_UINavigationController
//
//  Created by Scott on 16/3/17.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "VCOFSecond.h"
#import "VCOfThird.h"

@interface VCOFSecond ()

@property (nonatomic, retain) UIButton *button;

@end

@implementation VCOFSecond

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 修改navigationController的栈数组
    
    // 第一个界面对象
    UIViewController *first = self.navigationController.viewControllers[0];
    
    // 第三个界面对象.
    VCOfThird *third = [[VCOfThird alloc] init];
    
    // 第二个界面对象.
    UIViewController *second = self.navigationController.topViewController;
    
    [self.navigationController setViewControllers:@[first, third, second] animated:NO];
    
    
    [self configNaviBar];
    [self createButton];
    
}

- (void)createButton {
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    
    self.button.frame = CGRectMake(50, 80, self.view.frame.size.width - 100, 40);
    
    [self.button setTitle:@"Back" forState:UIControlStateNormal];
    
    [self.view addSubview:self.button];
    
    self.button.backgroundColor = [UIColor yellowColor];
    
    [self.button addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

/** 返回页面. */
- (void)backAction:(UIButton *)button {
    
    [self.navigationController popViewControllerAnimated:YES];

}



- (void)configNaviBar {
    
    self.navigationController.navigationBarHidden = YES;
}




#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
